package io;

import java.io.*;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;

public class DemoProperties {
    public static void main(String[] args) throws IOException {
        show03();
    }

    public static void show03() throws IOException {
        FileInputStream fis = new FileInputStream("c.txt");
        FileReader fr = new FileReader("c.txt");
        Properties prop = new Properties();
        prop.load(fr);
        Set<String> set = prop.stringPropertyNames();
        for (String s : set) {
            System.out.println(s);
            System.out.println(prop.getProperty(s));
        }
    }
    public static void show01(){
        Properties prop = new Properties();
        prop.setProperty("a", "123");
        prop.setProperty("b", "4123");
        prop.setProperty("c", "dfd");
        for (String s : prop.stringPropertyNames()) {
            System.out.println(s);
            System.out.println(prop.getProperty(s));
        }

    }
    public static void show02() throws IOException {
        Properties prop = new Properties();
        prop.setProperty("a", "123");
        prop.setProperty("b", "2123");
        prop.setProperty("c", "中文");
        /*FileWriter fw = new FileWriter("d.txt");
        prop.store(fw, "save data");
        fw.close();*/
        prop.store(new FileOutputStream("c.txt"),"");
    }
}
